home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 February / EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso / earcd / comm2 / termsorc.lha / Extras / Source / gtlayout-source.lha / LTP_DrawGroup.c < prev    next >
C/C++ Source or Header  |  1995-09-24  |  10KB  |  305 lines

  1. /*  GadTools layout toolkit
  2. **
  3. **  Copyright © 1993-1995 by Olaf `Olsen' Barthel
  4. **  Freely distributable.
  5. */
  6.  
  7. #include "gtlayout_global.h"
  8.  
  9. VOID __regargs
  10. LTP_DrawObjectLabel(LayoutHandle *Handle,ObjectNode *Node)
  11. {
  12.     LTP_SetPens(&Handle -> RPort,Handle -> TextPen,Handle -> BackgroundPen,JAM2);
  13.  
  14.     switch(Node -> LabelPlace)
  15.     {
  16.         case PLACE_LEFT:
  17.  
  18.             LTP_PrintLabel(Handle,Node,Node -> Left,Node -> Top + (Node -> Height - Handle -> RPort . TxHeight) / 2);
  19.             break;
  20.  
  21.         case PLACE_RIGHT:
  22.  
  23.             LTP_PrintLabel(Handle,Node,Node -> Left + Node -> Width + INTERWIDTH + INTERWIDTH + Node -> LabelWidth,Node -> Top + (Node -> Height - Handle -> RPort . TxHeight) / 2);
  24.             break;
  25.  
  26.         case PLACE_ABOVE:
  27.  
  28.             LTP_PrintLabel(Handle,Node,Node -> Left + (Node -> Width - Node -> LabelWidth) / 2 + INTERWIDTH + Node -> LabelWidth,Node -> Top - (Handle -> RPort . TxHeight + INTERHEIGHT));
  29.             break;
  30.  
  31.         case PLACE_BELOW:
  32.  
  33.             LTP_PrintLabel(Handle,Node,Node -> Left + (Node -> Width - Node -> LabelWidth) / 2 + INTERWIDTH + Node -> LabelWidth,Node -> Top + Node -> Height + INTERHEIGHT);
  34.             break;
  35.     }
  36. }
  37.  
  38. VOID __regargs
  39. LTP_DrawGroup(LayoutHandle *Handle,ObjectNode *Group)
  40. {
  41.     ObjectNode    *Node;
  42.     LONG         i;
  43.     ULONG         page;
  44.  
  45.     if(Group -> Label || Group -> Special . Group . Frame)
  46.         LTP_DrawLabel(Handle,Group);
  47.  
  48.     SCANPAGE(Group,Node,page)
  49.     {
  50.         switch(Node -> Type)
  51.         {
  52. #ifdef OLD_STYLE_DEFAULT_KEY
  53.             case BUTTON_KIND:
  54.  
  55.                 if(Handle -> ReturnKey == Node)
  56.                     LTP_DrawBevelBox(Handle,Node);
  57.  
  58.                 break;
  59. #endif
  60. #ifdef DO_GAUGE_KIND
  61.             case GAUGE_KIND:
  62.             {
  63.                 LONG Percent = Node -> Current;
  64.  
  65.                 Node -> Current = 0;
  66.  
  67.                 LTP_DrawGauge(Handle,Node,Percent,TRUE);
  68.  
  69.                 break;
  70.             }
  71. #endif
  72.             case PALETTE_KIND:
  73.  
  74.                 if(Node -> Special . Palette . UsePicker)
  75.                     LTP_DrawPalette(Handle,Node);
  76.  
  77.                 break;
  78.  
  79.             case GROUP_KIND:
  80.  
  81.                 if(Node -> Label)
  82.                     LTP_DrawLabel(Handle,Node);
  83.  
  84.                 LTP_DrawGroup(Handle,Node);
  85.  
  86.                 break;
  87.  
  88.             case XBAR_KIND:
  89.             {
  90.                 WORD Top = Node -> Top + ((Node -> Height + 1) / 2) - 1;
  91.  
  92.                 LockLayerRom(Handle -> RPort . Layer);
  93.  
  94.                 if(Node -> Special . Bar . FullSize)
  95.                 {
  96.                     LTP_SetAPen(&Handle -> RPort,Handle -> ShadowPen);
  97.                     Move(&Handle -> RPort,Handle -> Window -> BorderLeft,Top);
  98.                     Draw(&Handle -> RPort,Handle -> Window -> Width - (Handle -> Window -> BorderRight + 1),Top);
  99.  
  100.                     LTP_SetAPen(&Handle -> RPort,Handle -> ShinePen);
  101.                     Move(&Handle -> RPort,Handle -> Window -> BorderLeft,Top + 1);
  102.                     Draw(&Handle -> RPort,Handle -> Window -> Width - (Handle -> Window -> BorderRight + 1),Top + 1);
  103.                 }
  104.                 else
  105.                 {
  106.                     if(Node -> Special . Bar . Parent -> Label)
  107.                     {
  108.                         LTP_SetAPen(&Handle -> RPort,Handle -> ShadowPen);
  109.                         Move(&Handle -> RPort,Node -> Special . Bar . Parent -> Left + 2 * Handle -> GlyphWidth,Top + 1);
  110.                         Draw(&Handle -> RPort,Node -> Special . Bar . Parent -> Left + 2 * Handle -> GlyphWidth,Top);
  111.                         Draw(&Handle -> RPort,Node -> Special . Bar . Parent -> Left + Node -> Special . Bar . Parent -> Width - (2 * Handle -> GlyphWidth + 1) - 1,Top);
  112.  
  113.                         LTP_SetAPen(&Handle -> RPort,Handle -> ShinePen);
  114.                         Move(&Handle -> RPort,Node -> Special . Bar . Parent -> Left + 2 * Handle -> GlyphWidth + 1,Top + 1);
  115.                         Draw(&Handle -> RPort,Node -> Special . Bar . Parent -> Left + Node -> Special . Bar . Parent -> Width - (2 * Handle -> GlyphWidth + 1),Top + 1);
  116.                         Draw(&Handle -> RPort,Node -> Special . Bar . Parent -> Left + Node -> Special . Bar . Parent -> Width - (2 * Handle -> GlyphWidth + 1),Top);
  117.                     }
  118.                     else
  119.                     {
  120.                         LTP_SetAPen(&Handle -> RPort,Handle -> ShadowPen);
  121.                         Move(&Handle -> RPort,Node -> Special . Bar . Parent -> Left,Top + 1);
  122.                         Draw(&Handle -> RPort,Node -> Special . Bar . Parent -> Left,Top);
  123.                         Draw(&Handle -> RPort,Node -> Special . Bar . Parent -> Left + Node -> Special . Bar . Parent -> Width - 1,Top);
  124.  
  125.                         LTP_SetAPen(&Handle -> RPort,Handle -> ShinePen);
  126.                         Move(&Handle -> RPort,Node -> Special . Bar . Parent -> Left + 1,Top + 1);
  127.                         Draw(&Handle -> RPort,Node -> Special . Bar . Parent -> Left + Node -> Special . Bar . Parent -> Width - 1,Top + 1);
  128.                         Draw(&Handle -> RPort,Node -> Special . Bar . Parent -> Left + Node -> Special . Bar . Parent -> Width - 1,Top);
  129.                     }
  130.                 }
  131.  
  132.                 UnlockLayerRom(Handle -> RPort . Layer);
  133.  
  134.                 break;
  135.             }
  136.  
  137.             case YBAR_KIND:
  138.             {
  139.                 WORD Left = Node -> Left + ((Node -> Width + 1) / 2) - 1;
  140.  
  141.                 LockLayerRom(Handle -> RPort . Layer);
  142.  
  143.                 if(Node -> Special . Bar . Parent -> Label)
  144.                 {
  145.                     LTP_SetAPen(&Handle -> RPort,Handle -> ShadowPen);
  146.                     Move(&Handle -> RPort,Left + 1,Node -> Special . Bar . Parent -> Top + Handle -> RPort . TxHeight + Handle -> InterHeight);
  147.                     Draw(&Handle -> RPort,Left,Node -> Special . Bar . Parent -> Top + Handle -> RPort . TxHeight + Handle -> InterHeight);
  148.                     Draw(&Handle -> RPort,Left,Node -> Special . Bar . Parent -> Top + Node -> Special . Bar . Parent -> Height - (Handle -> RPort . TxHeight + Handle -> InterHeight + 1) - 1);
  149.  
  150.                     LTP_SetAPen(&Handle -> RPort,Handle -> ShinePen);
  151.                     Move(&Handle -> RPort,Left + 1,Node -> Special . Bar . Parent -> Top + Handle -> RPort . TxHeight + Handle -> InterHeight + 1);
  152.                     Draw(&Handle -> RPort,Left + 1,Node -> Special . Bar . Parent -> Top + Node -> Special . Bar . Parent -> Height - (Handle -> RPort . TxHeight + Handle -> InterHeight + 1));
  153.                     Draw(&Handle -> RPort,Left,Node -> Special . Bar . Parent -> Top + Node -> Special . Bar . Parent -> Height - (Handle -> RPort . TxHeight + Handle -> InterHeight + 1));
  154.                 }
  155.                 else
  156.                 {
  157.                     LTP_SetAPen(&Handle -> RPort,Handle -> ShadowPen);
  158.                     Move(&Handle -> RPort,Left + 1,Node -> Special . Bar . Parent -> Top);
  159.                     Draw(&Handle -> RPort,Left,Node -> Special . Bar . Parent -> Top);
  160.                     Draw(&Handle -> RPort,Left,Node -> Special . Bar . Parent -> Top + Node -> Special . Bar . Parent -> Height - 1 - 1);
  161.  
  162.                     LTP_SetAPen(&Handle -> RPort,Handle -> ShinePen);
  163.                     Move(&Handle -> RPort,Left + 1,Node -> Special . Bar . Parent -> Top + 1);
  164.                     Draw(&Handle -> RPort,Left + 1,Node -> Special . Bar . Parent -> Top + Node -> Special . Bar . Parent -> Height - 1);
  165.                     Draw(&Handle -> RPort,Left,Node -> Special . Bar . Parent -> Top + Node -> Special . Bar . Parent -> Height - 1);
  166.                 }
  167.  
  168.                 UnlockLayerRom(Handle -> RPort . Layer);
  169.  
  170.                 break;
  171.             }
  172.  
  173.             case FRAME_KIND:
  174.  
  175.                 if(Node -> Special . Frame . DrawBox)
  176.                     LTP_DrawBevelBox(Handle,Node);
  177.  
  178.                 if(Node -> Special . Frame . RefreshHook)
  179.                 {
  180.                     RefreshMsg Message;
  181.  
  182.                     Message . ID        = Node -> ID;
  183.                     Message . Left        = Node -> Left;
  184.                     Message . Top        = Node -> Top;
  185.                     Message . Width        = Node -> Width;
  186.                     Message . Height    = Node -> Height;
  187.  
  188.                     if(Node -> Special . Frame . DrawBox)
  189.                     {
  190.                         Message . Left        += 4;
  191.                         Message . Top        += 2;
  192.                         Message . Width        -= 8;
  193.                         Message . Height    -= 4;
  194.                     }
  195.  
  196.                     CallHookPkt(Node -> Special . Frame . RefreshHook,Handle,&Message);
  197.                 }
  198.  
  199.                 // FALL THROUGH TO...
  200.  
  201.             case BOOPSI_KIND:
  202.  
  203.                 // FALL THROUGH TO...
  204.  
  205.             case POPUP_KIND:
  206.  
  207.                 // FALL THROUGH TO...
  208.  
  209.             case TAPEDECK_KIND:
  210.  
  211.                 if(Node -> Label)
  212.                     LTP_DrawObjectLabel(Handle,Node);
  213.  
  214.                 break;
  215.  
  216.             case MX_KIND:
  217.  
  218.                 if(Node -> Label && !V39)
  219.                     LTP_PrintLabel(Handle,Node,Node -> Left,Node -> Top + (Node -> Height - Handle -> RPort . TxHeight) / 2 + 1);
  220.  
  221.                 break;
  222.  
  223.             case LISTVIEW_KIND:
  224.  
  225.                 if(Node -> Special . List . ExtraLabels)
  226.                 {
  227.                     LockLayerRom(Handle -> RPort . Layer);
  228.  
  229.                     LTP_SetPens(&Handle -> RPort,Handle -> TextPen,Handle -> BackgroundPen,JAM2);
  230.  
  231.                     for(i = 0 ; Node -> Special . List . ExtraLabels[i] ; i++)
  232.                     {
  233.                         LONG Len = strlen(Node -> Special . List . ExtraLabels[i]);
  234.  
  235.                         LTP_PlaceText(Handle,Node -> Special . List . ExtraLabels[i],Len,Node -> Left - (TextLength(&Handle -> RPort,Node -> Special . List . ExtraLabels[i],Len) + INTERWIDTH),Node -> Top + 2 + i * Handle -> RPort . TxHeight + Handle -> RPort . TxBaseline);
  236.                     }
  237.  
  238.                     UnlockLayerRom(Handle -> RPort . Layer);
  239.                 }
  240.  
  241.                 if(Node -> Label)
  242.                 {
  243.                     if(Node -> LabelPlace == PLACE_ABOVE && Node -> Special . List . FlushLabelLeft)
  244.                     {
  245.                         struct TextFont *Font = NULL,*OldFont;
  246.  
  247.                         if(Node -> Special . List . TextAttr)
  248.                         {
  249.                             if(Font = LTP_OpenFont(Node -> Special . List . TextAttr))
  250.                             {
  251.                                 OldFont = Handle -> RPort . Font;
  252.  
  253.                                 SetFont(&Handle -> RPort,Font);
  254.                             }
  255.                             else
  256.                                 break;
  257.                         }
  258.  
  259.                         LTP_PrintLabel(Handle,Node,Node -> Left + 2 + INTERWIDTH + Node -> LabelWidth,Node -> Top - (Handle -> RPort . TxHeight + INTERHEIGHT));
  260.  
  261.                         if(Font)
  262.                         {
  263.                             SetFont(&Handle -> RPort,OldFont);
  264.  
  265.                             CloseFont(Font);
  266.                         }
  267.                     }
  268.                     else
  269.                     {
  270.                         if(Node -> Special . List . TextAttr && Node -> Label)
  271.                             LTP_DrawObjectLabel(Handle,Node);
  272.                     }
  273.                 }
  274.  
  275.                 break;
  276.  
  277.             case BOX_KIND:
  278.  
  279.                 Node -> Special . Box . Parent = Group;
  280.  
  281.                 if(Node -> Special . Box . DrawBox)
  282.                     LTP_DrawBevelBox(Handle,Node);
  283.  
  284.                 LockLayerRom(Handle -> RPort . Layer);
  285.  
  286.                 for(i = 0 ; i < Node -> Lines ; i++)
  287.                 {
  288.                     if(Node -> Special . Box . Labels && Node -> Special . Box . Labels[i])
  289.                     {
  290.                         LONG Len = strlen(Node -> Special . Box . Labels[i]);
  291.  
  292.                         LTP_SetPens(&Handle -> RPort,Handle -> TextPen,Handle -> BackgroundPen,JAM2);
  293.                         LTP_PlaceText(Handle,Node -> Special . Box . Labels[i],Len,Node -> Left - (TextLength(&Handle -> RPort,Node -> Special . Box . Labels[i],Len) + INTERWIDTH),Node -> Top + 2 + i * Handle -> RPort . TxHeight + Handle -> RPort . TxBaseline);
  294.                     }
  295.  
  296.                     LTP_PrintBoxLine(Handle,Node,i);
  297.                 }
  298.  
  299.                 UnlockLayerRom(Handle -> RPort . Layer);
  300.  
  301.                 break;
  302.         }
  303.     }
  304. }
  305.